package com.chuangshi.core.vote.player.controller.mobile;

import com.chuangshi.core.exception.BusinessException;
import com.chuangshi.core.kit.Controller;
import com.chuangshi.core.vote.player.controller.mobile.request.PlayerMobileV1FindRequest;
import com.chuangshi.core.vote.player.controller.mobile.request.PlayerMobileV1ListRequest;
import com.chuangshi.core.vote.player.controller.mobile.response.PlayerMobileV1FindResponse;
import com.chuangshi.core.vote.player.controller.mobile.response.PlayerMobileV1ListResponse;
import com.chuangshi.core.vote.player.entity.Player;
import com.chuangshi.core.vote.player.service.PlayerService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * 人员信息移动端控制器
 *
 * @author ggliming
 * @date 2019-02-21
 */
@Api(tags = "人员信息移动端控制器")
@RestController
public class PlayerMobileController extends Controller {

    @Autowired
    private PlayerService playerService;

    @ApiOperationSort(value = 10)
    @ApiOperation(value = "获取人员信息列表", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "body", value = "请求参数", required = true, paramType = "body", dataType = "PlayerMobileV1ListRequest")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "返回参数", response = PlayerMobileV1ListResponse.class)
    })
    @RequestMapping(value = "/vote/player/mobile/v1/list", method = {RequestMethod.POST}, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, Object> v1List(@ApiIgnore @RequestBody PlayerMobileV1ListRequest body) {
        validateRequest(body);

        List<Player> playerList = playerService.listByPositionId(body);

        validateResponse(PlayerMobileV1ListResponse.class);

        return renderJson(playerList);
    }

    @ApiOperationSort(value = 20)
    @ApiOperation(value = "投票", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "body", value = "请求参数", required = true, paramType = "body", dataType = "PlayerMobileV1FindRequest")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "返回参数", response = PlayerMobileV1FindResponse.class)
    })
    @RequestMapping(value = "/vote/player/mobile/v1/voting", method = {RequestMethod.POST}, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, Object> v1Find(@ApiIgnore @RequestBody PlayerMobileV1FindRequest body) {
        validateRequest(body);

        PlayerMobileV1FindResponse response = playerService.voting(body.getPlayerId(), body.getObjectId(), body.getAppId());
        validateResponse(PlayerMobileV1FindResponse.class);

        return renderJson(response);
    }

//    @ApiOperationSort(value = 30)
//    @ApiOperation(value = "新增人员信息", httpMethod = "POST")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "body", value = "请求参数", required = true, paramType = "body", dataType = "PlayerMobileV1SaveRequest")
//    })
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "新增成功")
//    })
//    @RequestMapping(value = "/vote/player/mobile/v1/save", method = {RequestMethod.POST}, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
//    public Map<String, Object> v1Save(@ApiIgnore @RequestBody PlayerMobileV1SaveRequest body) {
//        validateRequest(body);
//
//        Boolean result = false;
//
//        return renderJson(result, result ? "新增成功" : "新增不成功");
//    }
//
//    @ApiOperationSort(value = 40)
//    @ApiOperation(value = "修改人员信息", httpMethod = "POST")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "body", value = "请求参数", required = true, paramType = "body", dataType = "PlayerMobileV1UpdateRequest")
//    })
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "修改成功")
//    })
//    @RequestMapping(value = "/vote/player/mobile/v1/update", method = {RequestMethod.POST}, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
//    public Map<String, Object> v1Update(@ApiIgnore @RequestBody PlayerMobileV1UpdateRequest body) {
//        validateRequest(body);
//
//        Boolean result = false;
//
//        return renderJson(result, result ? "修改成功" : "修改不成功");
//    }
//
//    @ApiOperationSort(value = 50)
//    @ApiOperation(value = "删除人员信息", httpMethod = "POST")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "body", value = "请求参数", required = true, paramType = "body", dataType = "PlayerMobileV1DeleteRequest")
//    })
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "删除成功")
//    })
//    @RequestMapping(value = "/vote/player/mobile/v1/delete", method = {RequestMethod.POST}, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
//    public Map<String, Object> v1Delete(@ApiIgnore @RequestBody PlayerMobileV1DeleteRequest body) {
//        validateRequest(body);
//
//        Boolean result = false;
//
//        return renderJson(result, result ? "删除成功" : "删除不成功");
//    }

}